//
//  RecommendEventsTableViewCell.m
//  LotteryProject
//
//  Created by yhj on 2017/7/11.
//  Copyright © 2017年 阳光. All rights reserved.
//

#import "RecommendEventsTableViewCell.h"

@interface RecommendEventsTableViewCell ()

@property(nonatomic,strong)UIImageView *imageUrl;

@property(nonatomic,strong)UILabel *nameLabel;

@property(nonatomic,strong)UILabel *detailLabel;

@end

@implementation RecommendEventsTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // ➡️Cell类型
        self.accessoryType=UITableViewCellAccessoryNone;

        self.imageUrl.hidden=NO;

        self.nameLabel.font=FontNumber(18);

        self.detailLabel.font=FontNumber(16);

        self.backgroundColor=WhiteColor;
    }
    return self;
}

-(UIImageView *)imageUrl
{
    if (!_imageUrl) {
        _imageUrl=[UIImageView new];
        _imageUrl.backgroundColor=MainColor;
        [self.contentView addSubview:self.imageUrl];
        [_imageUrl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin*2);
            make.width.mas_equalTo(kmargin*12);
            make.centerY.mas_equalTo(0);
            make.bottom.mas_equalTo(-kmargin);
            make.top.mas_equalTo(kmargin);
        }];
    }
    return _imageUrl;
}

// nameLabel
- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel=[self getLabelWithText:@"黄金大时代,支持中超联赛" font:FontNumber(18) textColor:DarkGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.imageUrl.mas_right).offset(kmargin*3/2);
            make.top.mas_equalTo(self.imageUrl.mas_top);
            make.right.mas_equalTo(-kmargin*2);
        }];
    }
    return _nameLabel;
}

// detailLabel
-(UILabel *)detailLabel
{
    if (!_detailLabel) {
        _detailLabel=[self getLabelWithText:@"美联储将于北京时间下周四2:00公布最新的利率决议,从美联储官员之前" font:FontNumber(16) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:2];
        [self.contentView addSubview:_detailLabel];
        [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(kmargin/2);
            make.left.mas_equalTo(self.nameLabel.mas_left);
            make.right.mas_equalTo(-kmargin*2);
        }];
    }
    return _detailLabel;
}

@end
